package com.cqrcb.cloud;

//import com.cqrcb.cloud.dubbo.entity.User;
//import com.cqrcb.cloud.dubbo.service.UserService;
//import org.apache.dubbo.config.annotation.DubboReference;
import com.alibaba.cloud.dubbo.annotation.DubboTransported;
import com.alibaba.cloud.sentinel.annotation.SentinelRestTemplate;
import com.cqrcb.cloud.handler.BlockExceptionUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.cloud.client.SpringCloudApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

import javax.annotation.PostConstruct;

/**
 * @author lengleng
 */
@EnableFeignClients
@EnableDiscoveryClient
@SpringCloudApplication
@EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class})
public class ServiceScheduleApplication {



	@Autowired
	@LoadBalanced
	private RestTemplate restTemplate;

	public static void main(String[] args) {
		SpringApplication.run(ServiceScheduleApplication.class, args);
	}

	@Bean
	@LoadBalanced
	@DubboTransported
	@SentinelRestTemplate(blockHandler = "handleException", blockHandlerClass = BlockExceptionUtil.class)
	public RestTemplate restTemplate() {
		return new RestTemplate();
	}

	@PostConstruct
	private void init() {

	}

}
